home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
yerk
/
mps231ss.hqx
/
Mops source
/
Toolbox classes
/
QD
< prev
next >
Wrap
Text File
|
1993-02-26
|
4KB
|
214 lines
\ QuickDraw support.
0 constant SRCCOPY \ equates for drawing modes
1 constant SRCOR
2 constant SRCXOR
\ Random - returns a random number 0 - N. N is limited to an Int
\ value. Larger than that means that numbers will be poorly distributed.
: RANDOM \ ( n -- rand*N )
word0 call Random word0 swap mod ;
\ Line drawing:
: HIDEPEN call HidePen ;
: SHOWPEN call ShowPen ;
\ ( horiz vert -- )
: MOVEPEN pack call Move ;
: MOVETO pack call MoveTo ;
: LINETO pack call LineTo ;
: LINE pack call Line ;
: DEL \ Draws a downward-pointing arrow to the right of and
\ below the current pen position - we need this for pop-up
\ menus. Any mathematician will recognize this symbol -
\ hence the name.
11 0 line -1 1 movePen
-9 0 line 1 1 movePen
7 0 line -1 1 movePen
-5 0 line 1 1 movePen
3 0 line -1 1 movePen
-1 0 line ;
\ ============= Patterns ===============
:class PATTERN super{ resource }
ptr CURR
:m GETNEW: \ ( pat# -- ptr )
'type PAT# swap set: self getnew: super
3 << ptr: self 2+ + put: curr ;m
:m GET: get: curr ;m
;class
objPtr TMPPTN class_is pattern
pattern SYSPATTN
: SYSPAT \ ( pat# -- ^pat-obj )
0 getnew: sysPattn
sysPattn ;
:class POINT super{ object }
int Y \ Vertical coordinate
int X \ Horizontal coordinate
:m GETX: inline{ get: x} get: x ;m
:m GETY: inline{ get: y} get: y ;m
:m PUTX: inline{ put: x} put: x ;m
:m PUTY: inline{ put: y} put: y ;m
:m SHIFTX: inline{ +: x} +: x ;m
:m SHIFTY: inline{ +: y} +: y ;m
:m SHIFT: inline{ +: y +: x} +: y +: x ;m
:m GET: get: X get: Y ;m
:m PUT: put: Y put: X ;m
:m INT: inline{ obj @} ^base @ ;m
:m ->: inline{ @ obj !} chksame @ ^base ! ;m
;class
:class RECT super{ object }
point TOPL
point BOTR
:m GET: get: topl get: botr ;m ( -- l t r b )
:m PUT: put: botr put: topl ;m ( l t r b -- )
:m GETTOP: get: topl ;m ( -- l t )
:m TOPINT: int: topl ;m
:m GETTOPX: getx: topl ;m
:m GETTOPY: gety: topl ;m
:m PUTTOP: put: topl ;m
:m PUTTOPX: putx: topl ;m
:m PUTTOPY: puty: topl ;m
:m GETBOT: get: botr ;m
:m BOTINT: int: botr ;m
:m GETBOTX: getx: botr ;m
:m GETBOTY: gety: botr ;m
:m PUTBOT: put: botr ;m
:m PUTBOTX: putx: botr ;m
:m PUTBOTY: puty: botr ;m
:m SIZE: \ ( -- width height ) Calculates rect's size
getx: botr getx: topl -
gety: botr gety: topl - ;m
:m SETSIZE: ( w h -- )
getTopY: self + putBotY: self
getTopX: self + putBotX: self ;m
:m GETCENTER: { \ x y -- x y }
size: self 2/ -> y 2/ -> x
getx: topl x + gety: topl y + ;m
:m INSET: \ ( dx dy -- ) Makes rect smaller by dx dy.
pack ^base swap call insetRect ;m
:m SHIFT: { dx dy -- }
dx dy or 0EXIT
dx dy shift: topL dx dy shift: botR ;m
:m OFFSET: shift: self ;m \ Old name - for compatibility
:m STRETCH: { dx dy -- } dx dy shift: botR ;m
:m ->: dup 4+ @ swap @ ^base ! ^base 4+ ! ;m
:m DRAW: ^base call framerect ;m
:m DISP: put: self draw: self ;m
:m CLEAR: ^base call eraserect ;m
:m FILL: \ ( ^patobj -- ) Fills rect with pattern
-> tmpPtn
get: tmpPtn ^base swap call fillrect ;m
:m DROPSHADOW: { \ lf top rt bot -- }
get: topL -> top -> lf
get: botR -> bot -> rt
draw: self
rt top 3+ moveto
0 bot top - 3- line
lf rt - 3+ 0 line ;m
:m INVERT: ^base call inverrect ;m
:m PAINT: ^base call paintrect ;m
:m CLIP: \ Clips drawing to this rect
^base call clipRect ;m
:m UPDATE: \ Adds rect to update region
^base call invalrect ;m
;class
fpRect ' rect set_class \ Make fpRect a rect object
\ A temporary rectangle, usable by anything
rect TEMPRECT
:class GRAFPORT super{ object }
16 bytes graf1 \ unmapped
rect PORTRECT
44 bytes graf2
var TEXT1 \ font,face,mode,size
var TEXT2
32 bytes graf3 \ unmapped
:m SET: \ Makes this grafport current
^base call setPort ;m
:m GETRECT: \ ( l t r b -- ) Gets values for portRect
get: portRect ;m
:m PUTRECT: \ ( l t r b -- ) Stores values for portRect
put: portRect ;m
;class
: PUSHPORT 0 sp@ call GetPort ;
: POPPORT call SetPort ;
\ ============= Cursors ==============
: CURSOR
<builds w,
does> 0 swap w@ makeint call GetCursor
>ptr call SetCursor ;
\ predefined cursors
1 cursor IBEAMCURS
2 cursor CROSSCURS
3 cursor PLUSCURS
4 cursor WATCHCURS
: ARROWCURS call InitCursor ;